package com.jinmdz.fmis.api.admin.controller;

import com.jinmdz.fmis.api.admin.model.loungehome.LoungeHomeIdData;
import com.jinmdz.fmis.api.admin.model.loungehome.LoungeHomeListData;
import com.jinmdz.fmis.api.admin.model.loungehome.LoungeHomeLoadData;
import com.jinmdz.fmis.api.admin.model.loungehome.LoungeHomeSaveData;
import com.jinmdz.fmis.api.admin.service.LoungeHomeService;
import com.jinmdz.fmis.api.api.model.common.IdVersionData;
import com.jinmdz.fmis.api.base.BaseController;
import com.jinmdz.fmis.core.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * 休息室信息
 *
 * @author SunZhaoQi
 * @date 2020/8/24 9:19
 */
@Api(description = "休息室信息相关接口")
@RestController()
@RequestMapping("/admin/lounge-home")
public class LoungeHomeController extends BaseController {

    @Resource
    private LoungeHomeService loungeHomeService;

    /**
     * 加载休息室信息
     *
     * @param
     * @return
     * @author SunZhaoQi
     * @date 2020/8/24 10:19
     */
    @ApiOperation(value = "加载休息室信息")
    @PostMapping("/load-lounge-home-list")
    public BaseResult<ArrayList<LoungeHomeListData>> loadLoungeHomeList() {
        return resultHandler(userItem -> loungeHomeService.loadLoungeHomeList());
    }

    /**
     * 加载休息室信息
     *
     * @param data 主键
     * @return
     * @author SunZhaoQi
     * @date 2020/8/24 13:14
     */
    @ApiOperation(value = "根据表中id加载休息室信息", notes = "根据ID加载休息室信息")
    @PostMapping("/load-lounge-home-with-id")
    public BaseResult<LoungeHomeLoadData> loadLoungeHomeWithId(@RequestBody LoungeHomeIdData data) {
        return resultHandler(data, userItem -> loungeHomeService.loadLoungeHomeWithId(data));
    }


    /**
     * 保存休息室信息
     *
     * @param data 休息室请求数据
     * @return
     * @author SunZhaoQi
     * @date 2020/8/24 14:56
     */
    @ApiOperation(value = "保存休息室信息到【lounge-home】表中", notes = "保存休息室信息到【lounge-home】表中")
    @PostMapping("/save-lounge-home")
    public BaseResult saveLoungeHome(@RequestBody LoungeHomeSaveData data) {
        return resultHandler(data, userItem -> loungeHomeService.saveLoungeHome(userItem, data));
    }

    /**
     * 从Lounge_Home表中删除指定id的休息室信息记录
     *
     * @param data 主键和版本号
     * @return
     * @author SunZhaoQi
     * @date 2020/8/25 09:22
     */
    @ApiOperation(value = "从Lounge_Home表中删除指定id的休息室信息记录", notes = "从Lounge_Home表中删除指定id的休息室信息")
    @PostMapping("/delete-lounge-home-with-id")
    public BaseResult deleteLoungeHomeWithId(@RequestBody ArrayList<IdVersionData> data) {
        return resultHandler(data, userItem -> loungeHomeService.deleteLoungeHomeWithId(userItem, data));
    }


}
